package com.gupaoedu.baifc.dynamicproxy.jdkproxy;

import com.gupaoedu.baifc.Person;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * projectName: baifc_proxy
 * packageName: com.gupaoedu.baifc.dynamicproxy.jdkproxy
 * Created: 2019/3/18.
 * Auther: baifc
 * Description:
 */
public class JDKProxyTest {

    public static void main(String[] args) {

        JDKMeipo jdkMeipo = new JDKMeipo();
        Person obj = (Person) jdkMeipo.getInstance(new Customer());

        byte[] bytes = ProxyGenerator.generateProxyClass("$proxy0", new Class[] {Person.class});
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("/Users/baifc/Downloads/$proxy0.class");
            fos.write(bytes);
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        obj.findLove();
    }
}
